﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ICarPool.BLL
{
    [Serializable]
    public struct SqlFilter
    {
        private string filterName;
        private string filterOperator;
        private object filterValue;
        private FilterType filterType;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The single field or combined fields to filter</param>
        /// <param name="operation">The filter operation on the field</param>
        /// <param name="val">The value to compare</param>
        /// <param name="type">The type of the field</param>
        public SqlFilter(string name, string operation, object val, FilterType type)
        {
            this.filterName = name.ToUpper();
            this.filterOperator = operation;
            this.filterValue = val;
            this.filterType = type;
        }

        /// <summary>
        /// The single field or combined fields to filter
        /// </summary>
        public string Name
        {
            get { return this.filterName; }
            set { this.filterName = value.ToUpper(); }
        }

        /// <summary>
        /// The filter operation on the field
        /// </summary>
        public string Operator
        {
            get { return this.filterOperator; }
            set { this.filterOperator = value; }
        }

        /// <summary>
        /// The value to compare
        /// </summary>
        public object Value
        {
            get { return this.filterValue; }
            set { this.filterValue = value; }
        }

        /// <summary>
        /// The type of the field
        /// </summary>
        public FilterType Type
        {
            get { return this.filterType; }
            set { this.filterType = value; }
        }
    }

    /// <summary>
    /// This structure contains the filter types
    /// </summary>
    public enum FilterType
    {
        /// <summary>
        /// String type, such as Varchar(20)
        /// </summary>
        String = 0,

        /// <summary>
        /// Numeric type, such as Int, Double
        /// </summary>
        Numeric = 1,

        /// <summary>
        /// DateTime type
        /// </summary>
        DateTime = 2,

        /// <summary>
        /// Bit type, either 1 or 0
        /// </summary>
        Boolean = 3,

        /// <summary>
        /// variant, combined, or funtion, such as getDate() in MS SQL Server
        /// </summary>
        Unknown = 4
    }
}
